/**
 */
package mvc_generator.mVCGenerator.impl;

import java.util.Collection;

import mvc_generator.mVCGenerator.DAO;
import mvc_generator.mVCGenerator.DatabaseTable;
import mvc_generator.mVCGenerator.MVCGeneratorPackage;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectResolvingEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>DAO</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link mvc_generator.mVCGenerator.impl.DAOImpl#getName <em>Name</em>}</li>
 *   <li>{@link mvc_generator.mVCGenerator.impl.DAOImpl#getInstanciatedDatabaseTable <em>Instanciated Database Table</em>}</li>
 *   <li>{@link mvc_generator.mVCGenerator.impl.DAOImpl#getUsedDAO <em>Used DAO</em>}</li>
 *   <li>{@link mvc_generator.mVCGenerator.impl.DAOImpl#getUsedDatabaseTables <em>Used Database Tables</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class DAOImpl extends MinimalEObjectImpl.Container implements DAO
{
  /**
   * The default value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected static final String NAME_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected String name = NAME_EDEFAULT;

  /**
   * The cached value of the '{@link #getInstanciatedDatabaseTable() <em>Instanciated Database Table</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getInstanciatedDatabaseTable()
   * @generated
   * @ordered
   */
  protected DatabaseTable instanciatedDatabaseTable;

  /**
   * The cached value of the '{@link #getUsedDAO() <em>Used DAO</em>}' reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getUsedDAO()
   * @generated
   * @ordered
   */
  protected EList<DAO> usedDAO;

  /**
   * The cached value of the '{@link #getUsedDatabaseTables() <em>Used Database Tables</em>}' reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getUsedDatabaseTables()
   * @generated
   * @ordered
   */
  protected EList<DatabaseTable> usedDatabaseTables;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected DAOImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return MVCGeneratorPackage.Literals.DAO;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getName()
  {
    return name;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setName(String newName)
  {
    String oldName = name;
    name = newName;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MVCGeneratorPackage.DAO__NAME, oldName, name));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public DatabaseTable getInstanciatedDatabaseTable()
  {
    if (instanciatedDatabaseTable != null && instanciatedDatabaseTable.eIsProxy())
    {
      InternalEObject oldInstanciatedDatabaseTable = (InternalEObject)instanciatedDatabaseTable;
      instanciatedDatabaseTable = (DatabaseTable)eResolveProxy(oldInstanciatedDatabaseTable);
      if (instanciatedDatabaseTable != oldInstanciatedDatabaseTable)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, MVCGeneratorPackage.DAO__INSTANCIATED_DATABASE_TABLE, oldInstanciatedDatabaseTable, instanciatedDatabaseTable));
      }
    }
    return instanciatedDatabaseTable;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public DatabaseTable basicGetInstanciatedDatabaseTable()
  {
    return instanciatedDatabaseTable;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setInstanciatedDatabaseTable(DatabaseTable newInstanciatedDatabaseTable)
  {
    DatabaseTable oldInstanciatedDatabaseTable = instanciatedDatabaseTable;
    instanciatedDatabaseTable = newInstanciatedDatabaseTable;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MVCGeneratorPackage.DAO__INSTANCIATED_DATABASE_TABLE, oldInstanciatedDatabaseTable, instanciatedDatabaseTable));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<DAO> getUsedDAO()
  {
    if (usedDAO == null)
    {
      usedDAO = new EObjectResolvingEList<DAO>(DAO.class, this, MVCGeneratorPackage.DAO__USED_DAO);
    }
    return usedDAO;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<DatabaseTable> getUsedDatabaseTables()
  {
    if (usedDatabaseTables == null)
    {
      usedDatabaseTables = new EObjectResolvingEList<DatabaseTable>(DatabaseTable.class, this, MVCGeneratorPackage.DAO__USED_DATABASE_TABLES);
    }
    return usedDatabaseTables;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case MVCGeneratorPackage.DAO__NAME:
        return getName();
      case MVCGeneratorPackage.DAO__INSTANCIATED_DATABASE_TABLE:
        if (resolve) return getInstanciatedDatabaseTable();
        return basicGetInstanciatedDatabaseTable();
      case MVCGeneratorPackage.DAO__USED_DAO:
        return getUsedDAO();
      case MVCGeneratorPackage.DAO__USED_DATABASE_TABLES:
        return getUsedDatabaseTables();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case MVCGeneratorPackage.DAO__NAME:
        setName((String)newValue);
        return;
      case MVCGeneratorPackage.DAO__INSTANCIATED_DATABASE_TABLE:
        setInstanciatedDatabaseTable((DatabaseTable)newValue);
        return;
      case MVCGeneratorPackage.DAO__USED_DAO:
        getUsedDAO().clear();
        getUsedDAO().addAll((Collection<? extends DAO>)newValue);
        return;
      case MVCGeneratorPackage.DAO__USED_DATABASE_TABLES:
        getUsedDatabaseTables().clear();
        getUsedDatabaseTables().addAll((Collection<? extends DatabaseTable>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case MVCGeneratorPackage.DAO__NAME:
        setName(NAME_EDEFAULT);
        return;
      case MVCGeneratorPackage.DAO__INSTANCIATED_DATABASE_TABLE:
        setInstanciatedDatabaseTable((DatabaseTable)null);
        return;
      case MVCGeneratorPackage.DAO__USED_DAO:
        getUsedDAO().clear();
        return;
      case MVCGeneratorPackage.DAO__USED_DATABASE_TABLES:
        getUsedDatabaseTables().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case MVCGeneratorPackage.DAO__NAME:
        return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
      case MVCGeneratorPackage.DAO__INSTANCIATED_DATABASE_TABLE:
        return instanciatedDatabaseTable != null;
      case MVCGeneratorPackage.DAO__USED_DAO:
        return usedDAO != null && !usedDAO.isEmpty();
      case MVCGeneratorPackage.DAO__USED_DATABASE_TABLES:
        return usedDatabaseTables != null && !usedDatabaseTables.isEmpty();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (name: ");
    result.append(name);
    result.append(')');
    return result.toString();
  }

} //DAOImpl
